package com.lifeng.mynetty.response;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * Created by lifeng
 * 2017/9/4 14:16
 */
public class ResponseCallBack {
    LinkedBlockingQueue<Object> queue = new LinkedBlockingQueue<Object>();

    public void callback(Object object) {
        queue.add(object);
    }

    public Object getMessageRes(int waitTime) throws InterruptedException {
        return (waitTime<0)?queue.take() : queue.poll(waitTime, TimeUnit.MILLISECONDS);
    }
}
